package com.app.sysmodule.utils;

import org.apache.log4j.Logger;
import org.springframework.core.io.support.PropertiesLoaderUtils;

import java.io.IOException;
import java.util.Properties;

/**
 * Created by song on 2017/8/22.
 * 获取配置文件通用方法
 */
public class PropertyUtils {
    public static final Logger log = Logger.getLogger(PropertyUtils.class);
    public static String getProperty(String key){
        try {
            Properties prop = PropertiesLoaderUtils.loadAllProperties("config.properties");
            Object object =  prop.get(key);
            if(null != object){
                log.info("key:"+key+"result:"+object);
                return (String) object;
            }else{
                return null;
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
}
